package ui.juego

import dominio.ubicaciones.Pais
import java.awt.Color
import org.uqbar.arena.bindings.PropertyAdapter
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.List
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import ui.juego.utilidades.IconUtils

class ViajarDialog extends Dialog<Viajar> {
	
	new(WindowOwner owner, Viajar model) {
		super(owner, model)
		title = "Viajar"
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {}
	
	override createMainTemplate(Panel mainPanel) {
		val viajarPanel = new Panel(mainPanel) => [
			layout = new VerticalLayout
		]
		val headPanel = new Panel(viajarPanel) => [
			layout = new ColumnLayout(2)
		]
		
		new Label(headPanel) => [
			text = "Estás en:"
			fontSize = 12
		]
		new Label(headPanel) => [
			bindValueToProperty("investigacion.paisActual.nombre")
			fontSize = 12
			foreground = Color.RED
		]
		new Label(viajarPanel) => [
			text = "|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡ ̴̡ı̴̴̡ ̡l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ |"
			fontSize = 14
			foreground = Color.BLACK
		]
		new List<Pais>(viajarPanel) => [
			bindItemsToProperty("paisesPosibles").adapter = new PropertyAdapter(Pais, "nombre")
			bindValueToProperty("destinoSeleccionado")
			width = 100
			
		]
		
		new Button(viajarPanel) => [
			caption = "Volver al País anterior"
			background = Color.ORANGE
			onClick[ |
				modelObject.volverAlPaisAnterior
				close
				new ResolverCasoWindow(this, modelObject.investigacion).open
			]
		] 
		new Button(viajarPanel) => [
			caption = '''Quedarse en «modelObject.investigacion.paisActual.nombre»'''
			background = Color.ORANGE
			onClick[ |
				close
				new ResolverCasoWindow(this, modelObject.investigacion).open
			]
		] 
		new Button(viajarPanel) => [
			caption = "Viajar"
			background = Color.ORANGE
			onClick[ |
				modelObject.viajarADestino
				close
				new ResolverCasoWindow(this, modelObject.investigacion).open
			]
		] 
	}
	
}